<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组的剩余方法</title>
    <script>
        var arr = ["孙悟空","猪八戒","沙和尚"];
        var arr2 = ["白骨精","玉兔精","蜘蛛精"];
        var arr3 = ["哪吒太子","二郎神","太上老君"];
        
        //concat()连接数组
        var result=arr.concat(arr2,arr3,"牛魔王","铁扇公主");
        console.log("result="+result);

        //join()转换
        var result=arr.join("and");
        console.log("result="+result);

        //reverse()反转
        var result=arr.reverse();
        console.log("result="+result);

        //sort()排序

        //默认排序
        arr=["a","f","e","b","g","d","c"]
        arr.sort();
        console.log(arr)

        //自定排序
        arr=[9,5,1,7,3,4,8,6,2]
        arr.sort(function(a,b){
            return a-b;
        })
        console.log(arr)


    </script>
</head>
<body>
    
</body>
</html>